import request from '@/utils/request'
import { parseStrEmpty } from "@/utils/ruoyi";

// 查询加工订单
export function queryProOrder(query) {
  return request({
    url: '/process/order/list',
    method: 'get',
    params: query
  })
}


// 查询加工订单详情
export function getProOrderInfo(orderCode) {
  return request({
    url: '/process/order/info/' + parseStrEmpty(orderCode),
    method: 'get'
  })
}

// 查询加工订单详情下所有任务
export function getProOrderDetail(query) {
  return request({
    url: '/process/order/detail/list',
    method: 'get',
    params: query
  })
}

// 删除加工订单
export function delProOrder(orderCodes) {
  return request({
    url: '/process/order/' + orderCodes,
    method: 'delete'
  })
}

// 新增加工订单
export function addProOrder(data) {
  return request({
    url: '/process/order/add',
    method: 'post',
    data: data
  })
}

// 修改加工订单
export function updateProOrder(data) {
  return request({
    url: '/process/order/update',
    method: 'put',
    data: data
  })
}

// 删除加工订单详情下的任务
export function delProOrderDetailByIds(orderIds) {
  return request({
    url: '/process/order/detail/' + orderIds,
    method: 'delete'
  })
}

// 删除加工订单详情下的任务
export function delOrderDetailById(orderId) {
  return request({
    url: '/process/order/detail/delete/' + orderId,
    method: 'delete'
  })
}

// 自动获取编号
export function getGenerateNumber(businessUnit) {
  return request({
    url: '/process/order/number/' + businessUnit,
    method: 'get'
  })
}

// 新增加工订单详情任务
export function addProOrderDetail(data) {
  return request({
    url: '/process/order/detail/add',
    method: 'post',
    data: data
  })
}

// 修改加工订单详情任务
export function updateProOrderDetail(data) {
  return request({
    url: '/process/order/detail/update',
    method: 'put',
    data: data
  })
}

// 拆分子任务
export function splitOrderTask(orderId,num) {
  const data = {
    orderId,
    num
  }
  return request({
    url: '/process/order/detail/split',
    method: 'put',
    data: data
  })
}